package com.hmall.api.item.client;

import com.hmall.api.item.dto.ItemDTO;
import com.hmall.api.item.dto.OrderDetailDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

/**
 * 商品服务Feign接口
 *
 * @Author mr.chen
 * @Date 2025/6/17 16:56
 */
//name:声明服务名称,path:相当于ItemController类上的@RequestMapping("/items")指定的路径
@FeignClient(name = "item-service",path = "/items")
public interface ItemClient {

    /**
     * 查询所有商品
     * @param ids
     * @return
     */
    @GetMapping
    List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    /**
     * 扣减库存
     * @param items
     */
    @PutMapping("/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);
}
